
package oreilly.command.control.macro;

import oreilly.command.control.Command;

/**
 * 使用巨集功能<br>
 * <br>
 * Copyright: Copyright (c) 2002-2007<br>
 * Company: E885 有限公司
 * 
 * @author Eric Gau(gau168.gau@msa.hinet.net)
 * @version 1.0
 */
public class MacroCommand implements Command
{
	/**
	 * 巨集功能
	 */
	Command commands[];

	/**
	 * constructor
	 * 
	 * @param commands 巨集功能
	 */
	public MacroCommand( Command[] commands )
	{
		this.commands = commands;
	}

	/**
	 * 巨集的執行功能
	 */
	public void execute()
	{
		int length = commands.length;

		for( int i = 0; i < length; i++ )
		{
			commands[ i ].execute();
		}
	}

	/**
	 * 巨集的復原功能
	 */
	public void undo()
	{
		int length = commands.length;

		for( int i = 0; i < length; i++ )
		{
			commands[ i ].undo();
		}
	}
}
